// $URL: http://mingw-lib.googlecode.com/svn/trunk/working/avcodec_to_widget_10/widget.h $
// $Rev: 344 $
// $Author: akio.miyoshi $
// $Date:: 2010-08-02 12:42:15 +0000#$

#ifndef WIDGET_H
#define WIDGET_H

#include "t_av_packet.h"
////#include "my_SDL_compat.h"

#include "misc.h"
#include "t_httpbackend.h"
#include "t_generator.h"
#include "t_box_player_ctx.h"
#include "input/t_box_seq.h"

class Widget;
class T_ScreenWidget : public QWidget
{
public:
    QSize m_size;
    class Widget *m_widget;
    QImage m_image;

    explicit T_ScreenWidget(Widget *parent);
    T_Box_Player_Context *playerContext();
    virtual void setScreenSize(QSize a_size)
    {
        m_size = a_size;
    }
    virtual QSize sizeHint () const
    {
        return m_size;
    }
    virtual void paintEvent(QPaintEvent *e);
};

namespace Ui {
    class Widget;
}
class T_Box_Input;
class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();

private:
    Ui::Widget *ui;
public:
    T_ScreenWidget *screenWidget;

    T_Box_Sequence *m_media_seq;
    T_Box_Input_Sequence *m_media_input;
    T_Box_Player_Context *m_player_ctx;

    QTimer m_video_timer;
    int m_drop_count;
    T_AutoRunFPS m_fps1;
    T_AutoRunFPS m_fps2;
    T_AutoRunFPS m_fps_download;


    QMutex m_frame_mutex;
    T_RecursiveAtomic m_packet_mutex;

    QAudioDeviceInfo m_device;
    QAudioFormat m_format;

    T_NetworkAccessManager m_nam;

    T_Box_Sequence *get_test_input();
    T_Box_Sequence *get_input_file(const QString &a_filename);
    T_Box_Sequence *get_input_youtube(const QString &a_video_id);
    T_Box_Sequence *get_input_youtube2(const QString &a_video_id, int a_fmt);

    void test_dump_format_ctx(AVFormatContext *a_format_ctx);

    void suspend_time();
    void resume_time();
    void show_status();

public slots:
    void onTimerTimeout();

private slots:
    void on_pushButton_2_clicked();
    void on_pushButton_clicked();
};

#endif // WIDGET_H
